package com.xjiye_test.payServer.servletGroup.shemmapay;

import com.xjiye_test.payServer.serverletInit.Config;
import com.xjiye_test.payServer.serverletUtil.*;
import net.sf.json.JSONObject;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;

/**
 * Created by Administrator on 2017/6/1.
 */
public class Notify extends HttpServlet {

    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setCharacterEncoding("UTF-8");
        PrintWriter out = resp.getWriter();
        String reStr=null;
        req.setCharacterEncoding("UTF-8");
        int size = req.getContentLength();
        InputStream is = req.getInputStream();
        reStr=new String(ReadBytes.readBytes(is, size));
//        JSONObject json= JsonUtil.toJSONObject(reStr);
        System.out.println("收到加密回调:"+reStr);
//        String bizconten=json.getString("biz_content");
//        try {
//            String resullt=PaySignature.rsaDecrypt(bizconten,Config.getConfig().getShenmapay_cus_private_key(), "UTF-8");
//            System.out.println("收到回调:"+resullt);
//        } catch (PlatformPayException e) {
//            e.printStackTrace();
//        }
        out.print("success");
        out.flush();
    }

    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req,resp);
    }
}
